<?php
	require_once(dirname(__FILE__)."./include/modify_data.php");
?>
<!DOCTYPE html>
<html>
<head>
	<title>设置您的个人信息</title>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="css/common.css" />
	<script language="javascript" type="text/javascript">
//<![CDATA[
function IsValidEmail( email )
{
	var regex = /^([0-9A-Za-z\-_\.]+)@([0-9a-z\-]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
	if ( regex.test( email ) )
		return true;
	else
		return false;
}

function CheckValid()
{
	if ( document.getElementById("nickname").value == "" )
	{
		window.alert("姓名不能为空");
		return false;
	}
	else if ( document.getElementById("email").value != "" && document.getElementById("email").value != "none"&& !IsValidEmail(document.getElementById("email").value) )
	{
		window.alert("电子邮件格式非法");
		return false;
	}
	else
		return true;
}
//]]>
</script>
	<style rel="stylesheet" type="text/css">
		.tag1{ width:30%;text-align:right;padding-right:30px}
		.tag2{ width:65%;text-align:left}
	</style>
</head>
<body>
	<table align="center" style="width:80%">
		<tr>
			<td>
				<?php require_once("header.php");?></td>
		</tr>
		<tr>
			<td>
				<form enctype="multipart/form-data" action="#" method="post" onsubmit="return CheckValid()">
					<table align="center" style="width:60%;padding-bottom:50px" border="0">
						<tr>
							<td colspan="2" style="text-align:center;padding-bottom:20px;padding-top:10px">
								<h2 style="color:purple">更新您的个人信息</h2>
							</td>
						</tr>
						<tr>
							<td colspan="2" style="text-align:center"></td>
						</tr>
						<tr>
							<td colspan="2" style="text-align:center;" >
								<img alt="my picture" src="<?php if($UserItem->imagesrc!='none') echo $UserItem->imagesrc;else echo 'images/no.jpg'; ?>" style="width:400px;padding-bottom:50px"/>
							</td>
						</tr>
						<tr>
							<td class="tag1">账号:</td>
							<td class="tag2">
								<?php echo htmlspecialchars($UserItem->username); ?>
								<span style="color:red;"><a href="./modify_psd.php">修改密码</a></span>
							</td>
						</tr>
						<tr>
							<td class="tag1">姓名:</td>
							<td>
								<input type="text" id="nickname" name="nickname" value="<?php echo htmlspecialchars($UserItem->nickname); ?>" class="tag2" required="required" />
								<span style="color:red">*[最大64个字]</span>
							</td>
						</tr>
						<tr>
							<td class="tag1">性别:</td>
							<td class="tag2">
								<select name="sex">
									<option <?php if($UserItem->sex=="男") echo "selected=\"selected\"";?>>男</option>
									<option <?php if($UserItem->sex=="女") echo "selected=\"selected\"";?>>女</option>
									<option <?php if($UserItem->sex=="秘密") echo "selected=\"selected\"";?>>秘密</option>
								</select>
								<span style="color:red">*</span>
							</td>
						</tr>
						<tr>
							<td class="tag1">学校:</td>
							<td>
								<input type="text" name="school" value="<?php echo htmlspecialchars($UserItem->school); ?>" class="tag2" />
								<span style="color:red">[最大128个字]</span>
								</td>
						</tr>
						<tr>
							<td class="tag1">照片:</td>
							<td class="tag2">
								<input type="hidden" name="MAX_FILE_SIZE" value="10240000"/>
								<input type="file" name="imagefile" value="选择照片" />
								<span style="color:red">&nbsp;[jpg/gif/png/bmp]</span>
							</td>
						</tr>
						<tr>
							<td class="tag1">邮箱:</td>
							<td>
								<input type="text" id="email" name="email" value="<?php echo htmlspecialchars($UserItem->email); ?>" class="tag2" /></td>
						</tr>
						<tr>
							<td class="tag1" valign="top">个人介绍:</td>
							<td>
								<textarea cols="1" rows="1" style="width:300px;height:150px" name="intra"><?php echo htmlspecialchars($UserItem->intra); ?></textarea>
								<p style="color:red">[最大10000个字]</p>
							</td>
						</tr>
						<tr>
							<td class="tag1"></td>
							<td class="tag2">
								<input type="submit" name="update" value="提交" />
							</td>
						</tr>
					</table>
				</form>
			</td>
		</tr>
		<tr>
			<td>
				<?php require_once("footer.php");?></td>
		</tr>
	</table>
</body>
</html>